/*  SSEventObject.h
 *  MESLib
 * 
 * Copyright 2003-2009 Starline Software Ltd
 * 
 * This file is part of MESLib.
 * 
 * MESLib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MESLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with MESLib. If not, see <http://www.gnu.org/licenses/>.
 */
//  Created by Tobias Haughton on Wed Jan 22 2003.



#import <Foundation/Foundation.h>
#import "SSEventView.h"
#import "SSChartDate.h"
#import "SSNeedsDiamond.h"
#import "SSConst.h"

@class SSEventLinkObject;

@interface SSEventObject : NSObject<NSCoding> {
   NSString *unique_id;
   NSString *actor;
   NSString *action;
   NSString *object;
   NSString *location;
   SSChartDate *beginTime;
   SSChartDate *endTime;
   NSArray *source;
   NSString *remark;
   NSMutableArray *linkArray;
   NSMutableArray *linkFromArray;
   NSString *address;
   SSEventView *eventView;
   NSNumber *label;
   NSMutableArray *needsDiamondArray;
   
   BOOL passedNSTest;
   BOOL isLoading;
   BOOL dataChanged;
   BOOL isVisible;
}

- (id)initWithUnique_id:(NSString *)unique
        actor:(NSString *)act
                 action:(NSString *)actio
                 object:(NSString *)obj
               location:(NSString *)loc
              beginTime:(SSChartDate *)begin
                endTime:(SSChartDate *)end
                 source:(NSArray *)sou
                 remark:(NSString *)rem
                address:(NSString *)add
                  label:(NSNumber *)lab
           passedNSTest:(BOOL)passed
              xPosition:(float)xPos
                  links:(NSMutableArray *)links;

- (id)initWithActor:(NSString *)act
             action:(NSString *)actio
             object:(NSString *)obj
           location:(NSString *)loc
          beginTime:(SSChartDate *)begin
            endTime:(SSChartDate *)end
             source:(NSArray *)sou
            remark:(NSString *)rem
            address:(NSString *)add
              label:(NSNumber *)lab;

- (id)initAsGhostEventWithAddress:(NSString *)add label:(NSNumber *)lab xPosition:(float)xPos;
- (id)initWithPboardRepresentation:(NSMutableDictionary *)dict xPos:(float)xPos;

- (NSString *)unique_id;
- (NSString *)actor;
- (NSString *)action;
- (NSString *)object;
- (NSString *)location;
- (SSChartDate *)beginTime;
- (SSChartDate *)endTime;
- (NSArray *)source;
- (NSString *)sourceString;
- (NSString *)remark;
- (NSMutableArray *)linkArray;
- (NSMutableArray *)linkFromArray;
- (NSString *)address;
- (NSString *)fileName;
- (SSEventView *)eventView;
- (NSNumber *)label;
- (NSString *)labelString;
- (NSMutableArray *)needsDiamondArray;
- (BOOL)passedNSTest;
- (BOOL)dataChanged;
- (BOOL)isVisible;

- (void)setUnique_id:(NSString *)string;
- (void)setActor:(NSString *)string;
- (void)setAction:(NSString *)string;
- (void)setObject:(NSString *)string;
- (void)setLocation:(NSString *)string;
- (void)setBeginTime:(SSChartDate *)cd;
- (void)setBeginTimeNoWarning:(SSChartDate *)cd;
- (void)setBeginTimeStatus:(BOOL)b;
- (void)setEndTime:(SSChartDate *)cd;
- (void)setEndTimeNoWarning:(SSChartDate *)cd;
- (void)setEndTimeStatus:(BOOL)b;
- (void)setSource:(NSArray *)array;
- (void)setRemark:(NSString *)remark;
- (void)setLinkArray:(NSMutableArray *)array;
- (void)setAddress:(NSString *)string;
- (void)setLabel:(NSNumber *)num;
- (void)setXPosition:(float)xPos;
- (void)setNeedsDiamondArray:(NSMutableArray *)array;
- (void)setPassedNSTest:(BOOL)passed;
- (void)setIsVisible:(BOOL)b;
- (NSMutableArray *)allRelatedNeedsDiamonds;
- (void)addNeedsDiamond:(SSNeedsDiamond *)diamond;
- (void)removeNeedsDiamond:(SSNeedsDiamond *)diamond;

- (BOOL)isVisible;
- (void)setIsVisible:(BOOL)b;

   //return info from view
- (NSRect)frame;
- (float)xPosition;
- (NSPoint)leftPoint;
- (NSPoint)rightPoint;
- (NSPoint)topPoint;
- (NSPoint)bottomPoint;
- (NSPoint)centerPoint;
- (NSPoint)leftTopPoint;
- (NSPoint)leftBottomPoint;
- (NSPoint)rightTopPoint;
- (NSPoint)rightBottomPoint;
- (NSPoint)topLeftPoint;
- (NSPoint)topRightPoint;
- (NSPoint)bottomLeftPoint;
- (NSPoint)bottomRightPoint;

- (NSPoint)positionForNeedsDiamond:(SSNeedsDiamond *)diamond;

- (void)strokeLinks;
- (void)strokeLinksForVisibleLinkedTo;
- (void)drawDiamonds;
- (void)replaceLinkWithName:(NSString *)name withEventLinkObject:(SSEventLinkObject *)linkObject;
- (void)updateLinks;
- (void)addLinkToObject:(SSEventObject *)linkedToEvent;
- (void)addLinkFrom:(SSEventObject *)linkFrom;
- (void)removeLinkMenuClick:(id)sender;
- (void)removeLinkFrom:(SSEventObject *)object;
- (void)removeLinkTo:(SSEventObject *)object;
- (void)removeAllLinks;
- (SSEventLinkObject *)linkObjectConnectingEvent:(SSEventObject *)event;

- (BOOL)hasLinkToObject:(SSEventObject *)event;
- (BOOL)hasLinkFromSameActor;
- (BOOL)hasNeedsDiamonds;

- (int)displayMode;

- (NSComparisonResult)compareByActor:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByAction:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByObject:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByLocation:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareBySource:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByBeginTime:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByEndTime:(SSEventObject *)otherEvent;
- (NSComparisonResult)compareByXPosition:(SSEventObject *)otherEvent;

- (NSString *)xmlStringRepresentation;
- (NSString *)xmlStringReferenceRepresentation;

@end
